Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openapi3: reference originating locations in YAML specs - step 1 #1007

Merged
merged 46 commits into from
Oct 21, 2024

Conversation

reuvenharrison
Copy link
Contributor

@reuvenharrison reuvenharrison commented Aug 25, 2024

This PR adds the ability to correlate OpenAPI components with the location in the originating YAML spec.
Here's a summary of the changes required to achieve this:

  1. Modify yaml.v3 to add line and column numbers of each YAML element to the unmarshaled interfaces (see https://github.com/oasdiff/yaml3)
  2. Modify invopop/yaml with a new function: UnmarshalWithOrigin (see https://github.com/oasdiff/yaml)
  3. Modify this repo to add an Origin struct to OpenAPI components. This requires changes to the UnmarshalJSON functions and, in some cases, replacing native types, like map[string]string, by dedicated types that include the original native type and an Origin member.

This PR addresses issue #986

Follow up tasks to be addressed by future PRs:

  • Add origin to more elements, namely Components and some types that are unmarshalled with unmarshalStringMapP or unmarshalStringMap
  • Merge changes in yaml.v3 and invopop/yaml back to original repos and remove replace directives from go.mod
  • Enhance origin to include end line and column and YAML comments as proposed by @fenollp

@reuvenharrison reuvenharrison marked this pull request as ready for review September 21, 2024 07:56
@reuvenharrison reuvenharrison changed the title Correlate OpenAPI components with their location in the originating YAML spec Add reference to originating locations in YAML specs - step 1 Sep 21, 2024
Copy link
Collaborator

@fenollp fenollp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few minor edits otherwise LGTM

openapi3/components.go Outdated Show resolved Hide resolved
openapi3/discriminator.go Outdated Show resolved Hide resolved
openapi3/security_scheme.go Outdated Show resolved Hide resolved
Jille and others added 7 commits October 16, 2024 13:58
* Add github.com/pb33f/libopenapi

it looks like a reasonable alternative

* Update README.md

---------

Co-authored-by: Pierre Fenoll <pierrefenoll@gmail.com>
* fix: issue unmarshalling when discriminator field is set in openapi2.0

* revert original approach

* update with different approach

* Revert "update with different approach"

This reverts commit 2db2b39.

* v2 schema with discriminator field set as string

* update ref link and comment

* run docs.sh
)

Signed-off-by: Pierre Fenoll <pierrefenoll@gmail.com>
@fenollp fenollp changed the title Add reference to originating locations in YAML specs - step 1 openapi3: reference originating locations in YAML specs - step 1 Oct 21, 2024
@fenollp fenollp merged commit c333b34 into getkin:master Oct 21, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants